﻿Imports LinqTo2DArray
Imports System.Linq

Module Test

    Sub Main()

        Dim oData As Object(,) = {{"OrderDate", "Region", "Rep", "Item", "Units", "Unit Cost", "Total"} _
            , {New DateTime(2011, 1, 6), "East", "Jones", "Pencil", 95, 1.99, 189.05} _
            , {New DateTime(2011, 1, 23), "Central", "Kivell", "Binder", 50, 19.99, 999.5} _
            , {New DateTime(2011, 2, 9), "Central", "Jardine", "Pencil", 36, 4.99, 179.64} _
            , {New DateTime(2011, 2, 26), "Central", "Gill", "Pen", 27, 19.99, 539.73} _
            , {New DateTime(2011, 3, 15), "West", "Sorvino", "Pencil", 56, 2.99, 167.44} _
            }
            
        Dim clsSales = oData.Parse(Of SaleOrder)(Function(o As Object()) New SaleOrder( _
                                             If(IsDate(o(0)), o(0), #1/1/1900#) _
                                             , o(1).ToString _
                                             , o(2).ToString _
                                             , o(3).ToString _
                                             , If(IsNumeric(o(4)), CInt(o(4)), 0) _
                                             , If(IsNumeric(o(5)), o(5), 0) _
                                             ), 1, 0, oData.GetUpperBound(0), 6)

        For Each cls In clsSales
            Console.WriteLine(cls.ToString)
        Next

        clsSales = Nothing
        clsSales = (New SaleOrders).ToObject(oData, True)

        For Each cls In clsSales
            Console.WriteLine(cls.ToString)
        Next

    End Sub

End Module
